from copy import deepcopy

items = [('name', 'Gumby'),('age', 42)]
d = dict(items)
print(d)
print(d['name'])

d = dict(name='Gumby', age=42)
print(d)

## clear
d = {}
d['name'] = 'Dumby'
d['age'] = 42
print(d)
returned_name = d.clear()
print(d)
print(returned_name)

# copy vs deepcopy
d = {}
d['names'] = ['Alfred', 'Bertrand']
print(d)
c = d.copy()
dc = deepcopy(d)
d['names'].append('huxin')
print(d)
print(c)
print(dc)

# fromkeys
print({}.fromkeys(['name', 'age']))
print(dict.fromkeys(['name', 'age']))
print(dict.fromkeys(['name', 'age'], 'unknown'))

# get

# items
d = {'title': 'Python Web Site', 'url': 'http://python.org', 'spam': 0}
items = d.items()
print(items)
print(len(items))
print(('spam', 0) in items)

# keys
print(list(d.keys()))

# pop
d = {'x': 0, 'y': 1}
print(d.pop('x'))
print(d)

# popitem
d = {'x': 0, 'y': 1}
print(d.popitem())

# setdefault
d = {}
d.setdefault('name', 'N/A')
print(d)
d['name'] = 'huxin'
d.setdefault('name', 'N/A')
print(d)

# update
